from django.shortcuts import render

# Create your views here.
from rest_framework.parsers import FileUploadParser, MultiPartParser, FormParser, JSONParser
from rest_framework.renderers import JSONRenderer, BrowsableAPIRenderer
from rest_framework.viewsets import ModelViewSet

from news.utils import StandardResultsSetPagination
from station.filters import StationFilter
from station.models import Station
from station.serializers import StationSerializer


class StationView(ModelViewSet):
    """
        list:
            站点列表
        retrieve:
            站点详情
        update:
            站点修改
        create:
            站点入住
        destroy:
            站点注销
    """
    parser_classes = [FormParser, MultiPartParser, JSONParser, ]
    renderer_classes = [JSONRenderer, BrowsableAPIRenderer, ]
    queryset = Station.objects.all()
    serializer_class = StationSerializer
    pagination_class = StandardResultsSetPagination
    filterset_class = StationFilter
    search_fields = ['station_name', 'address']
